package com.act.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import com.act.dao.ISumdayDao;
import com.act.domain.Sumday;
import com.act.dto.PagerDTO;
import com.act.service.api.ISumdayService;
import com.act.vo.PagerVo;

/**
* @Desccription:类说明
* @Author: 刘承军
* @E-mail:923050345@qq.com
* @Date:2017年11月6日 下午4:54:48  
*/
@Service
public class SumdayServiceImpl implements ISumdayService{
	
	@Resource
	private ISumdayDao sumdayDao;

	@Override
	public void add(Sumday sumday) {
		sumdayDao.add(sumday);
	}

	@Override
	public void update(Sumday sumday) {
		sumdayDao.update(sumday);
	}

	@Override
	public void delete(int id) {
		sumdayDao.delete(id);
	}


	@Override
	public PagerVo<Map> getNow(@Param("date") String date,@Param("pagerDTO") PagerDTO pagerDTO) {

		int start = pagerDTO.getStartIndex();
		int end = pagerDTO.getEndIndex();
		int total = sumdayDao.getCountsByDate(date);
		List<Map> lists = sumdayDao.getNow(date,start,end);
		PagerVo<Map> pagerVo = new PagerVo<>(pagerDTO.getPageIndex(),pagerDTO.getPageSize(),total,lists);
		return pagerVo;
	}

	@Override
	public PagerVo<Map> getByJobnum(@Param("jobnum")String jobnum,@Param("startTime") String startTime,@Param("endTime") String endTime, @Param("pagerDTO")PagerDTO pagerDTO) {
		int startIndex = pagerDTO.getStartIndex();
		int endIndex = pagerDTO.getEndIndex();
		int total = sumdayDao.getCountsByThree(jobnum,startTime,endTime);
		List<Map> lists = sumdayDao.getByJobnumTime(jobnum, startTime, endTime, startIndex, endIndex);
		PagerVo<Map> pagerVo = new PagerVo<>(pagerDTO.getPageIndex(),pagerDTO.getPageSize(),total,lists);
		
		return pagerVo;
	}

	@Override
	public Sumday getById(@Param("id")int id) {
		return sumdayDao.getById(id);
	}

	@Override
	public List<Sumday> getByIdInweek(@Param("jobnum")String jobnum) {
		return sumdayDao.getByIdInweek(jobnum);
	}
	
}
